// companyName: string; // 企业名称
// companyCode: string // 企业标识码
// legal: string; // 企业法人
// legalPhone: string; // 联系方式
// legalEmail: string; // 企业邮箱
// address: string; // 企业地址

import { InputItem, SelectItem, AsyncSelectItem } from '@/components/common-form/common-form-type';

const companyNameItem: InputItem = {
  name: 'input',
  prop: 'companyName',
  label: '企业名称',
  placeholder: '请输入企业名称',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '企业名称是必填项！',
      trigger: 'blur',
    },
  ],
};

const companyCodeItem: InputItem = {
  name: 'input',
  prop: 'companyCode',
  label: '标识码',
  placeholder: '请输入标识码',
  defaultValue: '',
  noEdit: true,
  rules: [
    {
      required: true,
      message: '标识码是必填项！',
      trigger: 'blur',
    },
  ],
};

const legalItem: InputItem = {
  name: 'input',
  prop: 'legal',
  label: '企业法人',
  placeholder: '请输入企业法人',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '企业法人是必填项！',
      trigger: 'blur',
    },
  ],
};

const legalPhoneItem: InputItem = {
  name: 'input',
  prop: 'legalPhone',
  label: '联系方式',
  placeholder: '请输入联系方式',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '联系方式是必填项！',
      trigger: 'blur',
    },
  ],
};

const legalEmailItem: InputItem = {
  name: 'input',
  prop: 'legalEmail',
  label: '企业邮箱',
  placeholder: '请输入企业邮箱',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '企业邮箱是必填项！',
      trigger: 'blur',
    },
  ],
};

const addressItem: InputItem = {
  name: 'input',
  prop: 'address',
  label: '企业地址',
  placeholder: '请输入企业地址',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '企业地址是必填项！',
      trigger: 'blur',
    },
  ],
};

// username: string; // 用户名
// role: Role; // 角色

// realname: string; // 真实姓名
// sex: Sex; // 性别
// phone: string; // 电话
// email: string; // 邮箱
// birth: Date; // 出生日期

const adminUsernameItem: InputItem = {
  name: 'input',
  prop: 'username',
  label: '用户名',
  placeholder: '请输入用户名',
  defaultValue: '',
  noEdit: true,
  rules: [
    {
      required: true,
      message: '用户名是必填项！',
      trigger: 'blur',
    },
  ],
};

const adminPasswordItem: InputItem = {
  name: 'input',
  type: 'password',
  prop: 'password',
  label: '密码',
  placeholder: '请输入密码',
  defaultValue: '',
  noEdit: true,
  rules: [
    {
      required: true,
      message: '密码是必填项！',
      trigger: 'blur',
    },
  ],
};

const adminRoleItem: SelectItem = {
  name: 'select',
  prop: 'role',
  label: '角色',
  placeholder: '请输入角色',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '角色是必填项！',
      trigger: 'blur',
    },
  ],
  options: () => [
    { label: '超级管理员', value: 0 },
    { label: '管理员', value: 1 },
    { label: '项目管理员', value: 2 },
    { label: '医生', value: 3 },
    { label: '文章管理员', value: 4 },
    { label: '产品维护', value: 5 },
  ],
};

const adminRealnameItem: InputItem = {
  name: 'input',
  prop: 'realname',
  label: '姓名',
  placeholder: '请输入姓名',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '姓名是必填项！',
      trigger: 'blur',
    },
  ],
};

const adminCompanyIdItem: AsyncSelectItem = {
  name: 'async-select',
  prop: 'companyId',
  label: '公司',
  placeholder: '请选择公司',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '公司是必填项！',
      trigger: 'blur',
    },
  ],
  url: '/company/options',
};

const adminSexItem: SelectItem = {
  name: 'select',
  prop: 'sex',
  label: '性别',
  placeholder: '请输入性别',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '性别是必填项！',
      trigger: 'blur',
    },
  ],
  options: () => [
    { label: '男', value: 1 },
    { label: '女', value: 0 },
  ],
};

const adminPhoneItem: InputItem = {
  name: 'input',
  prop: 'phone',
  label: '手机号',
  placeholder: '请输入手机号',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '手机号是必填项！',
      trigger: 'blur',
    },
  ],
};

const adminEmailItem: InputItem = {
  name: 'input',
  prop: 'email',
  label: '邮箱',
  placeholder: '请输入邮箱',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '邮箱是必填项！',
      trigger: 'blur',
    },
  ],
};

const adminBirthItem: InputItem = {
  name: 'input',
  prop: 'birth',
  label: '生日',
  placeholder: '请输入生日',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '生日是必填项！',
      trigger: 'blur',
    },
  ],
};

const roleNameItem = {
  name: 'input',
  prop: 'roleName',
  label: '角色名称',
  placeholder: '请输入角色名称',
  defaultValue: '',
  rules: [
    {
      required: true,
      message: '角色名称是必填项！',
      trigger: 'blur',
    },
  ],
};

export const companyFormItems = [companyNameItem, companyCodeItem, legalItem, legalPhoneItem, legalEmailItem, addressItem];
export const adminFormItems = [
  adminCompanyIdItem,
  adminUsernameItem,
  adminPasswordItem,
  adminRoleItem,
  adminRealnameItem,
  adminSexItem,
  adminPhoneItem,
  adminEmailItem,
  adminBirthItem,
];

export const userFormItems = [
  adminCompanyIdItem,
  adminUsernameItem,
  adminPasswordItem,
  adminRealnameItem,
  adminSexItem,
  adminPhoneItem,
  adminEmailItem,
  adminBirthItem,
];

export const roleFormItems = [roleNameItem];
